/* -*- c++ -*-
*
* bookmarkbar.h
*
* Copyright (C) 2005, 2006 Petter Stokke <ummo@hellokitty.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
*/

#ifndef DELICIOUSSIDEBAR_H
#define DELICIOUSSIDEBAR_H

#ifdef HAVE_CONFIG_H
#include <config.h>
#endif

#include <konqsidebarplugin.h>
#include <qstring.h>
#include <qvbox.h>
#include <kconfig.h>
#include <kparts/browserextension.h>

#include "bookmarkapi.h"
#include "deliciousapi.h"

class TagList;
class PostList;
class PrettyLabel;
class QSplitter;
class QTimer;
class KStatusBar;
class KComboBox;
class KProgress;
class KConfig;

class BookmarkBar : public KonqSidebarPlugin
{
    Q_OBJECT

public:
    BookmarkBar( KInstance *inst, QObject *parent, QWidget *widgetParent, QString &desktopName, const char* name = 0 );
    ~BookmarkBar();

    virtual QWidget *getWidget()
    {
        return m_top;
    }
    virtual void *provides( const QString & )
    {
        return 0;
    }

public slots:
    void setNewWindowByDefault( bool _newWindowByDefault );
    void submitURL( const KURL& url, const QStringList& tags );

signals:
    void openURLRequest( const KURL &url, const KParts::URLArgs &args );
    void createNewWindow( const KURL &url, const KParts::URLArgs &args );

protected:
    Collection *m_collection;
    DeliciousAPI *m_api;
    QVBox *m_top, *m_main;
    QSplitter *m_splitter;
    TagList *m_tagList;
    PostList *m_postList;
    PrettyLabel *m_topLabel, *m_postLabel;
    KStatusBar* m_statusBar;
    KProgress* m_progressBar;
    KComboBox* m_search;
    QTimer* m_searchTimer;
    KConfig* m_config;
    virtual void handleURL( const KURL &url );
    void loadCache();

private slots:
    void slotUpdateStatusText( const QString& text );
    void slotUpdateProgress( KIO::filesize_t processed, KIO::filesize_t total );
    void slotClearStatusBar();
    void slotRefresh();
    // void slotFetchUserIfNeeded();
    void slotRecoverFromError();
    void slotGotPosts( BookmarkAPIJob* job );
    void slotTagRenamed( const QString& oldTag, const QString& newTag );
    void slotSetPostTitle( const QString& title );
    void slotSearchTyping();
    void slotSearch();
    void slotSubmitSearch( const QString& );
    void setDeliciousUser( const QString& user );
    void loadTags( const QStringList& tags );
    /*
    void loadGlobalTag(const QString& tag);
    void slotGotGlobalTag(const QValueList<Post>& posts, const QString& tag);
    */
    void openPostDefaultAction( Post* post );
    void openPost( Post* post );
    void openPostInNewWindow( Post* post );
    void editPost( Post* post );

};

#endif
